package com.snail.generator.common;

import com.snail.generator.mapper.GeneratorMapper;

import java.sql.Connection;

public class WebContext {
    private static final ThreadLocal<Connection> dataSourceConnection = new ThreadLocal<>();
    private static final ThreadLocal<GeneratorMapper> generatorMapper = new ThreadLocal<>();

    public static void setDataSourceConnection(Connection dataSourceName) {
        WebContext.dataSourceConnection.set(dataSourceName);
    }

    public static Connection getDataSourceConnection() {
        return dataSourceConnection.get();
    }

    public static void removeDataSourceConnection() {
        dataSourceConnection.remove();
    }

    public static void setGeneratorMapper(GeneratorMapper mapper) {
        generatorMapper.set(mapper);
    }

    public static GeneratorMapper getGeneratorMapper() {
        return generatorMapper.get();
    }
}
